package org.zuel.boot.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zuel.boot.demo.entity.StudentResume;
import org.zuel.boot.demo.entity.SysUser;
import org.zuel.boot.demo.service.IStudentResumeService;
import org.zuel.boot.demo.service.impl.SessionService;
import org.zuel.boot.demo.web.JsonResult;
import org.zuel.boot.demo.web.PageParam;
import org.zuel.boot.demo.web.PageResult;

import javax.servlet.http.HttpServletRequest;

/**
 *  控制器
 *
 * @author ikun
 */
@Api(tags = "管理")
@RestController
@RequestMapping("/zuel")
public class StudentResumeController {
    @Autowired
    private SessionService sessionService;

    private final IStudentResumeService StudentResumeService;

    @Autowired
    public StudentResumeController(IStudentResumeService StudentResumeService){
        this.StudentResumeService = StudentResumeService;
    }

    @ApiOperation("查询列表")
    @GetMapping("/studentResume/list")
    public PageResult<StudentResume> list(HttpServletRequest request) {
        PageParam<StudentResume> pageParam = new PageParam<>(request);
        return StudentResumeService.list(pageParam);
    }

    @ApiOperation("查询单个")
    @GetMapping("/studentResume/get")
    public JsonResult read(HttpServletRequest request) {
        SysUser user = sessionService.validateSession1(request);
        return StudentResumeService.read(user);
    }

    @ApiOperation("添加")
    @PostMapping("/studentResume/add")
    public JsonResult add(@RequestBody StudentResume model) {
    return StudentResumeService.add(model);
    }

    @ApiOperation("修改")
    @PostMapping("/studentResume/update")
    public JsonResult update(@RequestBody StudentResume model,HttpServletRequest request) {
        SysUser user = sessionService.validateSession1(request);
        return StudentResumeService.update(model,user);
    }

    @ApiOperation("删除")
    @GetMapping("/studentResume/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return StudentResumeService.delete(ids);
    }

}